<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css">   
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/icon.css">
<!-- 引入Js -->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>个人密码修改</title>
</head>
<script type="text/javascript">
    //判断两次输入的新密码是否一致
   $(function(){
    	$("#newpswagain").blur(function(){
    		var  newpsw = $("#newpsw").val();
    		var names = $(this).val().trim();
    		var len=names.length;
    		var  newpswagain = $(this).val();
    		if(newpsw==newpswagain&&len>=6&&len<=10){
    			$.messager.alert('提示','密码一致可以提交');	
    		}else if(newpsw!=newpswagain){
    			$.messager.alert('提示','密码不一致，请重新输入','info',function(){
					$("#updatepswform").form('clear');
				});	
    		}else {
    			$.messager.alert('提示','请重新输入密码长度在6到10位之间','info',function(){
					$("#updatepswform").form('clear');
				});	
    		}
    	});
    });
    //密码提交
    function updatepsw(){
    	$("#updatepswform").form("submit",{	
		    onSubmit: function(){    	
			var oldpsw=$("#oldpsw").val();
			var newpsw=$("#newpsw").val();
			var newpswagain=$("#newpswagain").val();
			if(oldpsw==""){	
				$.messager.alert('提示','请输入原密码','info',function(){
					$("#updatepswform").form('clear');	
				});
				return false;	
			}else if(oldpsw==newpsw&&newpsw==newpswagain){
				$.messager.alert('提示','新密码和原密码不能一致','info',function(){
					$("#updatepswform").form('clear');
				});
				return false;
			}else if(oldpsw!=""&&newpswagain==""){
				$.messager.alert('提示','请输入新密码','info',function(){
					$("#updatepswform").form('clear');
				});
				return false;
			}else{
				return true;
			}	
		    },
		    success:function(data){
		    	$("#updatepswform").form('clear');
		    	if(data=="true"){
	    			//提示修改成功
		    		$.messager.alert('提示','密码修改成功','info',function(){
						window.location.herf("login.jsp");
					});
	    		}else if(data=="false"){
	    			//提示修改失败
	    			$.messager.alert('提示','密码修改失败,原密码不正确'); 
	    		}else{
	    			//提示修改失败
	    			$.messager.alert('提示','密码修改失败');
	    		}
		    }
		});	
    }
    //密码输入须知
    function pswshow(){
    	$.messager.alert('提示','密码输入只能输入“英文”、“数字”、“.\@\,\$\%\&\*\!\~\#\^”的符号，请按规则输入');
    }
</script>
<body >
	    <div id="checkwin" class="easyui-window" title="修改个人密码" style="width:300px;height:280px; " data-options="modal:true,closable:false,collapsible:false,minimizable:false,maximizable:false,draggable:false" >
    	<form id="updatepswform" style="padding:10px 20px 10px 40px; " method="post" action="updatepsw" >
    		<p>原密码: <input id="oldpsw"  name="oldpsw" class="easyui-validatebox" style="width:200px" data-options="required:true,missingMessage:'请输入原密码'" onKeyUp="value=value.replace(/[^\a-\z\A-\Z0-9\.\@\,\$\%\&\*\!\~\#\^]/g,'');" onpaste="return false" oncontextmenu="return false;"></p>
    		<p>新密码: <input id="newpsw" name="newpsw" class="easyui-validatebox" style="width:200px" data-options="required:true,missingMessage:'请输入新密码'" onKeyUp="value=value.replace(/[^\a-\z\A-\Z0-9\.\@\,\$\%\&\*\!\~\#\^]/g,'');"  onpaste="return false" oncontextmenu="return false;"></p>
    		<p>重复输入新密码: <input id="newpswagain" name="newpswagain" class="easyui-validatebox" style="width:200px" data-options="required:true,missingMessage:'请重复输入新密码'" onKeyUp="value=value.replace(/[^\a-\z\A-\Z0-9\.\@\,\$\%\&\*\!\~\#\^]/g,'');" onpaste="return false" oncontextmenu="return false;"></p>
    		<div style="padding:5px;text-align:center;">
    			<a href="#" class="easyui-linkbutton" icon="icon-ok" onclick="updatepsw()">确认</a>
    			<a href="#" class="easyui-linkbutton" icon="icon-reload">清除</a>
    			<a href="#" class="easyui-linkbutton" icon="icon-search" onclick="pswshow()">密码输入规则须知</a>
    		</div>
    	</form>
    </div>   
</body>
</html>